package cn.xmy.demo01.service.impl;
import cn.xmy.demo01.dao.AddressDao;
import cn.xmy.demo01.pojo.Address;
import cn.xmy.demo01.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    AddressDao addressDao;

    @Override
    public List<Address> findAllAddress() throws SQLException, ClassNotFoundException {
        return addressDao.findAllAddress();
    }

    @Override
    public int addAddress(Address address) throws SQLException, ClassNotFoundException {
        return addressDao.addAddress(address);
    }

    @Override
    public int updateAddress(Address address) throws SQLException, ClassNotFoundException {
        return addressDao.updateAddress(address);
    }

    @Override
    public int deleteAddress(String id) throws SQLException, ClassNotFoundException {
        return addressDao.deleteAddress(id);
    }

    @Override
    public Address findAllAddressById(String id) throws SQLException, ClassNotFoundException {
        return addressDao.findAllAddressById(id);
    }

    @Override
    public int isDefaultAddress(String id) throws SQLException, ClassNotFoundException {
        return addressDao.isDefaultAddress(id);
    }

    @Override
    public Address getDefaultAddress(String id) throws SQLException, ClassNotFoundException {
        return addressDao.getDefaultAddress(id);
    }

    @Override
    public void resetDefaultAddresses() {
        addressDao.resetDefaultAddresses();
    }

    @Override
    public void setDefaultAddress(String id) {
        addressDao.setDefaultAddress(id);

    }


    @Override
    public List<Address> findDefaultAddress() throws SQLException, ClassNotFoundException {
        return addressDao.findDefaultAddress();
    }

}
